home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 April / april_2001.iso / intercd / root / ^Palm / Games / eCross / src / Wall.java < prev   
Encoding:
Java Source  |  2000-07-25  |  2.1 KB  |  75 lines

  1. /*
  2.  * Wall.java - THe 'walled' border
  3.  * Copyright (C) 2000 Romain Guy
  4.  * guy.romain@bigfoot.com
  5.  * www.jext.org
  6.  *
  7.  * This program is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU General Public License
  9.  * as published by the Free Software Foundation; either version 2
  10.  * of the License, or any later version.
  11.  *
  12.  * This program is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  * GNU General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU General Public License
  18.  * along with this program; if not, write to the Free Software
  19.  * Foundation, Inc., 59 Temple Place - Suite 331, Boston, MA  02111-1307, USA.
  20.  */
  21.  
  22. import waba.fx.*;
  23.  
  24. /**
  25.  * This class stands for a border which represents a brick wall.
  26.  * @author Romain Guy <guy.romain@bigfoot.com>
  27.  * @version 1.0
  28.  */
  29.  
  30. public class Wall
  31. {
  32.   // pattern infos
  33.   public static final byte PATTERN_WIDTH = 10;
  34.   public static final byte PATTERN_HEIGHT = 6;
  35.   // the length in pixels of the wall (width and height)
  36.   private int lengthX, lengthY;
  37.   // the pattern picture
  38.   private Image patternImage;
  39.  
  40.   public Wall(int lengthX, int lengthY)
  41.   {
  42.     this.lengthX = lengthX;
  43.     this.lengthY = lengthY;
  44.  
  45.     patternImage = new Image("datas/wall.bmp");
  46.   }
  47.  
  48.   public void paint(Graphics g)
  49.   {
  50.     g.setColor(0, 0, 0);
  51.     g.drawLine(0, lengthY - 1, lengthX, lengthY - 1);
  52.  
  53.     int num = lengthX / PATTERN_WIDTH;
  54.     for (int i = 0; i < num; i++)
  55.     {
  56.       g.drawImage(patternImage, i * PATTERN_WIDTH, 15);
  57.       g.drawImage(patternImage, i * PATTERN_WIDTH, lengthY - PATTERN_HEIGHT - 1);
  58.     }
  59.  
  60.     num = (lengthY - 15) / PATTERN_HEIGHT;
  61.     for (int i = 1; i < num - 1; i++)
  62.     {
  63.       g.drawImage(patternImage, 0, 15 + i * PATTERN_HEIGHT);
  64.       g.drawImage(patternImage, lengthX - PATTERN_WIDTH, 15 + i * PATTERN_HEIGHT);
  65.     }
  66.   }
  67.  
  68.   public void free()
  69.   {
  70.     patternImage.free();
  71.   }
  72. }
  73.  
  74. // End of Wall.java
  75.